package com.itboye.ihomebank.responsitory;

import com.google.gson.reflect.TypeToken;
import com.itboye.ihomebank.base.BaseNetRepository;
import com.itboye.ihomebank.base.ICompleteListener;
import com.itboye.ihomebank.base.MyApplcation;
import com.itboye.ihomebank.bean.BangDingBean;
import com.itboye.ihomebank.bean.BeiFenKeyBean;
import com.itboye.ihomebank.bean.DownBeifenBean;
import com.itboye.ihomebank.bean.HouseBean;
import com.itboye.ihomebank.bean.KaiSuoJiLu;
import com.itboye.ihomebank.bean.KaiSuoJiLuTwo;
import com.itboye.ihomebank.bean.KeysBean;
import com.itboye.ihomebank.bean.MessWeiDuBean;
import com.itboye.ihomebank.bean.RentInfoBean;
import com.itboye.ihomebank.constants.SPContants;
import com.itboye.ihomebank.interfaces.KeyInterface;
import com.itboye.ihomebank.net.BaseErrorListener;
import com.itboye.ihomebank.net.BaseSuccessReqListener;
import com.itboye.ihomebank.net.ByJsonRequest.Builder;
import com.itboye.ihomebank.util.SPUtils;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/***
 * 钥匙请求网络类
 * 
 */
public class KeyRepository extends BaseNetRepository implements
		KeyInterface<HouseBean> {

	private String api = "100";

	private String register = "BY_ScienerV3_reg";// 注册
	private String addmain = "BY_ScienerV3_init";//  锁初始化(v3)
	private String kaisuo = "BY_ScienerV3_listRecord";// 开锁记录(v3)
	private String youxiaoqi = "BY_ScienerV3_changePeriod";// 修改钥匙有效期(v3)7
	private String dongjie = "BY_ScienerV3_lockKey";// 冻结钥匙(v3)
	private String jiedong = "BY_ScienerV3_unlockKey";// 解冻钥匙(v3)
	private String shanchu = "BY_ScienerV3_deleteKey";// 删除钥匙(v3)
	private String beifen = "BY_Sciener_backupKey";// 备份钥匙
	private String shouquan = "BY_ScienerV3_auth";// 授权钥匙(v3)

	private String jianpanPass = "BY_ScienerV3_resetKeyboardPwd";// 重置键盘密码(v3)
	private String beifenList = "BY_Sciener_listBackup";// 备份钥匙列表
	private String DeleteBeifen = "BY_Sciener_deleteBackup";// 删除备份钥匙
	private String downBeifen = "BY_Sciener_downBackup";// 下载备份钥匙
	private String sendJianPanPass = "BY_ScienerV3_getKeyboardPwd";// 发送键盘密码(v3)
	private String xinxi = "BY_Repair_setlockinfo";//获取锁信息
	private String yuyue = "BY_Repair_addlock";//预约装锁
	private String tuisong = "BY_Sciener_ifPush";//锁推送

	private String fankui = "BY_User_suggest";// 意见反馈
	private String weidu = "BY_Message_count";//消息未读
	private String yidu = "BY_Message_read";//消息已读

	private String my_key="BY_ScienerV3_listUserKey";//我的钥匙（v3）--已改

	private String judge="BY_Sciener2_isRegSitri";//判断白马云锁是否注册
	private String regSitri="BY_Sciener2_regSitri";//注册白马云锁
	private String initSitri="BY_Sciener2_initSitri";//锁初始化-白马锁（绑定到服务器）
	private String rentInfo="BY_Sciener2_getRentInfo";//获取租户信息--发送钥匙的时候用到。当该用户的这把锁绑定了房源，获取到该客户的信息
	private String setPower="BY_Sciener2_setPower";//设置锁电量

	public KeyRepository(ICompleteListener iCompleteListener) {
		super(iCompleteListener);
	}

	/**
	 * 注册
	 */
	@Override
	public void getRegister(String uid) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("uid", uid);
		(new Builder<String>())
				.setTypeVerParamsAndReturnClass(register, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<String>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();

	}

	/**
	 *  锁初始化(v3)
     */
	@Override
	public void getAddMain(String uid, String lock_type, String lockName,
			String lockAlias, String lockMac, String lockKey,
			String lockFlagPos, String aesKeyStr, String version,
						   String adminPwd,String noKeyPwd,String deletePwd,String pwdInfo,String timestamp,String specialValue,int electricQuantity) {
		Type type = new TypeToken<BangDingBean>() {
		}.getType();
		boolean islock= (boolean) SPUtils.get(MyApplcation.ctx,null, SPContants.ISLOCK,false);
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		if (islock){
			map.put("sid", uid);
		}else {
			map.put("uid", uid);
		}
		map.put("lock_type", lock_type);
		map.put("lockName", lockName);
		map.put("lockAlias", lockAlias);
		map.put("lockMac", lockMac);
		map.put("lockKey", lockKey);
		map.put("lockFlagPos", lockFlagPos);
		map.put("aesKeyStr", aesKeyStr);
		map.put("lockVersion", version);
		map.put("adminPwd", adminPwd);
		map.put("noKeyPwd", noKeyPwd);
		map.put("deletePwd", deletePwd);
		map.put("pwdInfo", pwdInfo);
		map.put("timestamp", timestamp);
		map.put("specialValue", specialValue);
		map.put("electricQuantity",electricQuantity);
		if (islock){
			(new Builder<BangDingBean>(islock))
					.setTypeVerParamsAndReturnClass(addmain, apiVer, map, type)
					.requestListener(
							new BaseSuccessReqListener<BangDingBean>(getListener(),islock))
					.errorListener(new BaseErrorListener(getListener()))
					.desEncodeThenBuildAndSend();
		}else {
			(new Builder<BangDingBean>())
					.setTypeVerParamsAndReturnClass(addmain, apiVer, map, type)
					.requestListener(
							new BaseSuccessReqListener<BangDingBean>(getListener()))
					.errorListener(new BaseErrorListener(getListener()))
					.desEncodeThenBuildAndSend();
		}


	}

	/**
	 * 开锁记录
	 */
	@Override
	public void getKaiSuoJiLu(String uid, String lock_id, String current_page,
			String per_page) {
		Type type = new TypeToken<KaiSuoJiLuTwo>() {
		}.getType();
		boolean islock= (boolean) SPUtils.get(MyApplcation.ctx,null, SPContants.ISLOCK,false);
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		if (islock){
			map.put("sid", uid);
		}else {
			map.put("uid", uid);
		}
		map.put("lock_id", lock_id);
		map.put("current_page", current_page);
		map.put("per_page", per_page);
		if (islock){
			(new Builder<KaiSuoJiLuTwo>(islock))
					.setTypeVerParamsAndReturnClass(kaisuo, apiVer, map, type)
					.requestListener(
							new BaseSuccessReqListener<KaiSuoJiLuTwo>(getListener(),islock))
					.errorListener(new BaseErrorListener(getListener()))
					.desEncodeThenBuildAndSend();
		}else {
			(new Builder<KaiSuoJiLuTwo>())
					.setTypeVerParamsAndReturnClass(kaisuo, apiVer, map, type)
					.requestListener(
							new BaseSuccessReqListener<KaiSuoJiLuTwo>(getListener()))
					.errorListener(new BaseErrorListener(getListener()))
					.desEncodeThenBuildAndSend();
		}

	}

	@Override
	public void getYouXiaoQi(String uid, String key_id, String lock_id, String start, String end) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("uid", uid);
		map.put("lock_id", lock_id);
		map.put("key_id", key_id);
		map.put("start", start);
		map.put("end", end);
		(new Builder<String>())
				.setTypeVerParamsAndReturnClass(youxiaoqi, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<String>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

	/**
	 * 冻结钥匙
	 */
	@Override
	public void getDongJie(String uid, String to_uid, String lock_id,
			String key_id) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		boolean islock= (boolean) SPUtils.get(MyApplcation.ctx,null,SPContants.ISLOCK,false);
		Map<String, Object> map = new HashMap<String, Object>();
		if (islock){
			map.put("sid", uid);
		}else {
			map.put("uid", uid);
		}
		map.put("to_uid", to_uid);
		map.put("lock_id", lock_id);
		map.put("key_id", key_id);
		if (islock){
			(new Builder<String>(islock))
					.setTypeVerParamsAndReturnClass(dongjie, apiVer, map, type)
					.requestListener(
							new BaseSuccessReqListener<String>(getListener(),islock))
					.errorListener(new BaseErrorListener(getListener()))
					.desEncodeThenBuildAndSend();
		}else {
			(new Builder<String>())
					.setTypeVerParamsAndReturnClass(dongjie, apiVer, map, type)
					.requestListener(
							new BaseSuccessReqListener<String>(getListener(),islock))
					.errorListener(new BaseErrorListener(getListener()))
					.desEncodeThenBuildAndSend();
		}


	}

	/**
	 * 解冻钥匙
	 */
	@Override
	public void getJieDong(String uid, String to_uid, String lock_id,
			String key_id) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;

		Map<String, Object> map = new HashMap<String, Object>();
		boolean islock= (boolean) SPUtils.get(MyApplcation.ctx,null,SPContants.ISLOCK,false);

		if (islock){
			map.put("sid", uid);
		}else {
			map.put("uid", uid);
		}
		map.put("to_uid", to_uid);
		map.put("lock_id", lock_id);
		map.put("key_id", key_id);
		if (islock){
			(new Builder<String>(islock))
					.setTypeVerParamsAndReturnClass(jiedong, apiVer, map, type)
					.requestListener(
							new BaseSuccessReqListener<String>(getListener(),islock))
					.errorListener(new BaseErrorListener(getListener()))
					.desEncodeThenBuildAndSend();
		}else {
			(new Builder<String>())
					.setTypeVerParamsAndReturnClass(jiedong, apiVer, map, type)
					.requestListener(
							new BaseSuccessReqListener<String>(getListener(),islock))
					.errorListener(new BaseErrorListener(getListener()))
					.desEncodeThenBuildAndSend();
		}


	}

	@Override
	public void getShouQuan(String uid, String to_uid, String lock_id, String auth, String start, String end) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		boolean islock= (boolean) SPUtils.get(MyApplcation.ctx,null,SPContants.ISLOCK,false);

		if (islock){
			map.put("sid", uid);
		}else {
			map.put("uid", uid);
		}
		map.put("to_uid", to_uid);
		map.put("lock_id", lock_id);
		map.put("auth", auth);
		map.put("start", start);
		map.put("end", end);
		if (islock){
			(new Builder<String>(islock))
					.setTypeVerParamsAndReturnClass(shouquan, apiVer, map, type)
					.requestListener(
							new BaseSuccessReqListener<String>(getListener(),islock))
					.errorListener(new BaseErrorListener(getListener()))
					.desEncodeThenBuildAndSend();
		}else {
			(new Builder<String>())
					.setTypeVerParamsAndReturnClass(shouquan, apiVer, map, type)
					.requestListener(
							new BaseSuccessReqListener<String>(getListener(),islock))
					.errorListener(new BaseErrorListener(getListener()))
					.desEncodeThenBuildAndSend();
		}

	}

	@Override
	public void getShanChu(String uid, String to_uid, String lock_id,
			String key_id) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		boolean islock= (boolean) SPUtils.get(MyApplcation.ctx,null,SPContants.ISLOCK,false);

		if (islock){
			map.put("sid", uid);
		}else {
			map.put("uid", uid);
		}
		map.put("to_uid", to_uid);
		map.put("lock_id", lock_id);
		map.put("key_id", key_id);
		if (islock){
			(new Builder<String>(islock))
					.setTypeVerParamsAndReturnClass(shanchu, apiVer, map, type)
					.requestListener(
							new BaseSuccessReqListener<String>(getListener(),islock))
					.errorListener(new BaseErrorListener(getListener()))
					.desEncodeThenBuildAndSend();
		}else {
			(new Builder<String>())
					.setTypeVerParamsAndReturnClass(shanchu, apiVer, map, type)
					.requestListener(
							new BaseSuccessReqListener<String>(getListener()))
					.errorListener(new BaseErrorListener(getListener()))
					.desEncodeThenBuildAndSend();
		}


	}

	@Override
	public void getBeiFei(String uid, String lock_Id, String key_id,
			String admin_ps, String nokey_ps, String delete_ps) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("uid", uid);
		map.put("lock_id", lock_Id);
		map.put("key_id", key_id);
		map.put("admin_ps", admin_ps);
		map.put("nokey_ps", nokey_ps);
		map.put("delete_ps", delete_ps);
		(new Builder<String>())
				.setTypeVerParamsAndReturnClass(beifen, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<String>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();

	}

	/**
	 * 重置键盘密码
	 */
	@Override
	public void getJianPanPass(String uid, String lock_id, String pwd_info,
			String timestamp) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
        boolean islock= (boolean) SPUtils.get(MyApplcation.ctx,null,SPContants.ISLOCK,false);

        if (islock){
            map.put("sid", uid);
        }else {
            map.put("uid", uid);
        }
		map.put("lock_id", lock_id);
		map.put("pwd_info", pwd_info);
		map.put("timestamp", timestamp);
		if (islock){
            (new Builder<String>(islock))
                    .setTypeVerParamsAndReturnClass(jianpanPass, apiVer, map, type)
                    .requestListener(
                            new BaseSuccessReqListener<String>(getListener(),islock))
                    .errorListener(new BaseErrorListener(getListener()))
                    .desEncodeThenBuildAndSend();
        }else {
            (new Builder<String>())
                    .setTypeVerParamsAndReturnClass(jianpanPass, apiVer, map, type)
                    .requestListener(
                            new BaseSuccessReqListener<String>(getListener(),islock))
                    .errorListener(new BaseErrorListener(getListener()))
                    .desEncodeThenBuildAndSend();
        }


	}

	/**
	 * 备份钥匙列表
	 */
	@Override
	public void getBeifeiList(String uid) {
		Type type = new TypeToken<List<BeiFenKeyBean>>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
        boolean islock= (boolean) SPUtils.get(MyApplcation.ctx,null,SPContants.ISLOCK,false);

        if (islock){
            map.put("sid", uid);
        }else {
            map.put("uid", uid);
        }

        if (islock){
            (new Builder<List<BeiFenKeyBean>>(islock))
                    .setTypeVerParamsAndReturnClass(beifenList, apiVer, map, type)
                    .requestListener(
                            new BaseSuccessReqListener<List<BeiFenKeyBean>>(
                                    getListener()))
                    .errorListener(new BaseErrorListener(getListener()))
                    .desEncodeThenBuildAndSend();
        }else {
            (new Builder<List<BeiFenKeyBean>>())
                    .setTypeVerParamsAndReturnClass(beifenList, apiVer, map, type)
                    .requestListener(
                            new BaseSuccessReqListener<List<BeiFenKeyBean>>(
                                    getListener()))
                    .errorListener(new BaseErrorListener(getListener()))
                    .desEncodeThenBuildAndSend();
        }


	}

	/**
	 * 删除备份钥匙
	 */
	@Override
	public void getDeleteBeiFen(String uid, String lock_id, String key_id) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
        boolean islock= (boolean) SPUtils.get(MyApplcation.ctx,null,SPContants.ISLOCK,false);

        if (islock){
            map.put("sid", uid);
        }else {
            map.put("uid", uid);
        }
		map.put("lock_id", lock_id);
		map.put("key_id", key_id);

        if (islock){
            (new Builder<String>(islock))
                    .setTypeVerParamsAndReturnClass(DeleteBeifen, apiVer, map, type)
                    .requestListener(
                            new BaseSuccessReqListener<String>(getListener(),islock))
                    .errorListener(new BaseErrorListener(getListener()))
                    .desEncodeThenBuildAndSend();
        }else {
            (new Builder<String>())
                    .setTypeVerParamsAndReturnClass(DeleteBeifen, apiVer, map, type)
                    .requestListener(
                            new BaseSuccessReqListener<String>(getListener(),islock))
                    .errorListener(new BaseErrorListener(getListener()))
                    .desEncodeThenBuildAndSend();
        }


	}

	/**
	 * 下载备份钥匙
	 */
	@Override
	public void getDownKeyBeiFen(String uid, String lock_id, String key_id) {
		Type type = new TypeToken<DownBeifenBean>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
        boolean islock= (boolean) SPUtils.get(MyApplcation.ctx,null,SPContants.ISLOCK,false);

        if (islock){
            map.put("sid", uid);
        }else {
            map.put("uid", uid);
        }
		map.put("lock_id", lock_id);
		map.put("key_id", key_id);
        if (islock){
            (new Builder<DownBeifenBean>(islock))
                    .setTypeVerParamsAndReturnClass(downBeifen, apiVer, map, type)
                    .requestListener(
                            new BaseSuccessReqListener<DownBeifenBean>(
                                    getListener(),islock))
                    .errorListener(new BaseErrorListener(getListener()))
                    .desEncodeThenBuildAndSend();
        }else {
            (new Builder<DownBeifenBean>())
                    .setTypeVerParamsAndReturnClass(downBeifen, apiVer, map, type)
                    .requestListener(
                            new BaseSuccessReqListener<DownBeifenBean>(
                                    getListener(),islock))
                    .errorListener(new BaseErrorListener(getListener()))
                    .desEncodeThenBuildAndSend();
        }


	}

	/**
	 * 发送键盘密码
	 */
	@Override
	public void getKeyboardPwd(String uid, String lock_id, String pwd_type,
			String to_phone, String start, String end, String date) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
        boolean islock= (boolean) SPUtils.get(MyApplcation.ctx,null,SPContants.ISLOCK,false);

        if (islock){
            map.put("sid", uid);
        }else {
            map.put("uid", uid);
        }
		map.put("lock_id", lock_id);
		map.put("pwd_type", pwd_type);
		map.put("to_phone", to_phone);
		map.put("start", start);
		map.put("end", end);
		map.put("date", date);
		map.put("app_time", date);
        if (islock){
            (new Builder<String>(islock))
                    .setTypeVerParamsAndReturnClass(sendJianPanPass, apiVer, map,
                            type)
                    .requestListener(
                            new BaseSuccessReqListener<String>(getListener(),islock))
                    .errorListener(new BaseErrorListener(getListener()))
                    .desEncodeThenBuildAndSend();
        }else {
            (new Builder<String>())
                    .setTypeVerParamsAndReturnClass(sendJianPanPass, apiVer, map,
                            type)
                    .requestListener(
                            new BaseSuccessReqListener<String>(getListener(),islock))
                    .errorListener(new BaseErrorListener(getListener()))
                    .desEncodeThenBuildAndSend();
        }


	}

	/**
	 * 意见反馈
	 */
	@Override
	public void getFankui(String uid, String content) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("uid", uid);
		map.put("content", content);

		(new Builder<String>())
				.setTypeVerParamsAndReturnClass(fankui, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<String>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();

	}
	/**
	 * 获取锁信息
	 */
	@Override
	public void getSuoXinXi() {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();

		(new Builder<String>())
				.setTypeVerParamsAndReturnClass(xinxi, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<String>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
		
	}
	/**
	 * 预约装锁
	 */
	@Override	
	public void getYuYue(String uid, String name, String mobile, String address) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("uid", uid);
		map.put("name", name);
		map.put("mobile", mobile);
		map.put("address", address);
		(new Builder<String>())
				.setTypeVerParamsAndReturnClass(yuyue, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<String>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
		
	}
	/**
	 * 锁推送
	 */
	@Override
	public void getTuiSong(String uid, String lock_id, String push) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("uid", uid);
		map.put("lock_id", lock_id);
		map.put("push", push);
		(new Builder<String>())
				.setTypeVerParamsAndReturnClass(tuisong, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<String>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
		
	}
	/**
	 * 消息未读
	 */
	@Override
	public void getWeiDu(String uid) {
		Type type = new TypeToken<MessWeiDuBean>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("uid", uid);
		(new Builder<MessWeiDuBean>())
				.setTypeVerParamsAndReturnClass(weidu, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<MessWeiDuBean>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
		
	}
	/**
	 * 消息已读
	 */
	@Override
	public void getYiDu(String uid, String id) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("uid", uid);
		map.put("id", id);
		(new Builder<String>())
				.setTypeVerParamsAndReturnClass(yidu, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<String>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

	@Override
	public void myKey(String uid, String kword,boolean isLock) {
		Type type = new TypeToken<List<KeysBean>>() {
		}.getType();
		String apiVer = api;
//		boolean lock= (boolean) SPUtils.get(MyApplcation.ctx,null,SPContants.ISLOCK,false);
		if (isLock){
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("sid", uid);
			map.put("kword", kword);
			(new Builder<List<KeysBean>>(true))
					.setTypeVerParamsAndReturnClass(my_key, apiVer, map, type)
					.requestListener(
							new BaseSuccessReqListener<List<KeysBean>>(getListener(),isLock))
					.errorListener(new BaseErrorListener(getListener()))
					.desEncodeThenBuildAndSend();
		}else {
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("uid", uid);
			map.put("kword", kword);
			(new Builder<List<KeysBean>>())
					.setTypeVerParamsAndReturnClass(my_key, apiVer, map, type)
					.requestListener(
							new BaseSuccessReqListener<List<KeysBean>>(getListener(),isLock))
					.errorListener(new BaseErrorListener(getListener()))
					.desEncodeThenBuildAndSend();
		}

	}
	/**
	 * 判断是否注册白马锁
	 */
	@Override
	public void onJudge(String uid) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("uid", uid);
		(new Builder<String>())
				.setTypeVerParamsAndReturnClass(judge, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<String>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}
	/**
	 * 注册白马锁
	 */
	@Override
	public void regSitri(String uid) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("uid", uid);
		(new Builder<String>())
				.setTypeVerParamsAndReturnClass(regSitri, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<String>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}
	/**
	 * 锁初始化-白马锁（绑定到服务器）
	 * @param uid
	 * @param lockMac
	 * @param lockName
	 * @param lockAlias
	 * @param app_time		时间
	 * @param pwdInfo   	SDK返回的锁列表数据
	 */
	@Override
	public void initSitri(String uid, String lockMac, String lockName, String lockAlias, String app_time, String pwdInfo) {
		Type type = new TypeToken<BangDingBean>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		boolean lock= (boolean) SPUtils.get(MyApplcation.ctx,null,SPContants.ISLOCK,false);
		if(lock){
			map.put("sid", uid);
			map.put("lockMac", lockMac);
			map.put("lockName", lockName);
			map.put("lockAlias", lockAlias);
			map.put("app_time", app_time);
			map.put("pwdInfo", pwdInfo);

			(new Builder<BangDingBean>(lock))
					.setTypeVerParamsAndReturnClass(initSitri, apiVer, map, type)
					.requestListener(
							new BaseSuccessReqListener<BangDingBean>(getListener(),lock))
					.errorListener(new BaseErrorListener(getListener()))
					.desEncodeThenBuildAndSend();
		}else {
			map.put("uid", uid);
			map.put("lockMac", lockMac);
			map.put("lockName", lockName);
			map.put("lockAlias", lockAlias);
			map.put("app_time", app_time);
			map.put("pwdInfo", pwdInfo);

			(new Builder<BangDingBean>())
					.setTypeVerParamsAndReturnClass(initSitri, apiVer, map, type)
					.requestListener(
							new BaseSuccessReqListener<BangDingBean>(getListener()))
					.errorListener(new BaseErrorListener(getListener()))
					.desEncodeThenBuildAndSend();
		}

	}
	/**
	 * 获取租户信息--发送钥匙的时候用到。当该用户的这把锁绑定了房源，获取到该客户的信息
	 */
	@Override
	public void onRentInfo(String uid, String lock_id) {
		Type type = new TypeToken<RentInfoBean>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("uid", uid);
		map.put("lock_id", lock_id);

		(new Builder<RentInfoBean>())
				.setTypeVerParamsAndReturnClass(rentInfo, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<RentInfoBean>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

	@Override
	public void onSetPower(String uid, String lock_id, int power) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("uid", uid);
		map.put("lock_id", lock_id);
		map.put("power", power);
		(new Builder<String>())
				.setTypeVerParamsAndReturnClass(setPower, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<String>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}


}
